<!DOCTYPE html>
<html>
	<head>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			#mycanvas{
				display: block;
				background: #ccc;
			}
		</style>
	</head>
	<body>
		<canvas id="mycanvas" width="600" height="400"></canvas>
	</body>
	
	<script>
		//加载器
		function draw(){
			let dom = document.querySelector('#mycanvas');
			let ctx = dom.getContext('2d');
			
			//保存无变形状态
			ctx.save();
			//填充色
			ctx.fillStyle = "#00F";
			//移动
			ctx.translate(105,105);
			//旋转
			ctx.rotate(0.2)
			//缩放
			ctx.scale(1,2);
			//变形集合
			// ctx.transform(1,0.5,-0.5,1,30,10);
			//绘制
			ctx.fillRect(15,15,120,120);
			//恢复到无变形状态
			ctx.restore();
			//再次渲染一个矩形
			ctx.fillRect(30,30,200,200);
		};
		
		console.log(new draw())
	</script>
</html>
